#ifndef USER_H_INCLUDED
#define USER_H_INCLUDED

#include <string>
#include <iostream>
#include <list>
#include <map>
#include <fstream>
#include <stdio.h>

#include "./../Socket/rwSocket.h"
#include "./../Command/command.h"

using namespace std;

struct UserConsts
{
	string userName;
	string passWord;
	string nowRoomID;

	UserConsts()
	{
		userName = "USERNAME";
		passWord = "PASSWORD";
		nowRoomID = "NOWROOMID";
	};
};

const UserConsts Const;


class User
{
	public:
		struct UserProfiles
		{
			string passWord; //Keep here
		
			rwSocket *Socket;
			int iLoginStatus;
			bool isLogined;
			string strUserInput;
			int ierrorTimes;
			int iSameCommand;
			bool blNeedKickOut;// set to TRUE will kickout user.
			
			UserProfiles()
			{
				iLoginStatus = 1;
				isLogined = false;
				strUserInput = "";
				ierrorTimes = 0;
				iSameCommand = 0;
				blNeedKickOut = false;
			}
		};

		User(string);
		User();
		~User();
		UserProfiles UserProfile;
		long longLastCMDTime;
		map<string, string> UserData;

		void CommandHandler(string);
		bool Auth();
		bool IsUserExist();
		bool Save();
		bool Load();
		void OutputMessage(string);
		void KickOut();
		//void usurpUserControler(Socket*);
		void dump();
	private:
		void init(string);
		string getUserFileFullPath();
		command cmd;
	protected:
};

#endif // UTILITY_H_INCLUDED
